﻿using MyManager.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;


namespace MyManager.Data
{
    public class TaskXMLDataManager : ITaskDataManager
    {
        TaskCollection _taskCollection;

        public TaskXMLDataManager()
        {
            _taskCollection = XMLHelper.deserializeXMLToObject<TaskCollection>();
            if (null == _taskCollection) _taskCollection = new TaskCollection();
            
            
        }

        public MyManager.Business.Task Create(Business.Task task)
        {
            task.Id = XMLHelper.getUniqueId();
            _taskCollection.Add(task);
            int result=XMLHelper.serializeObjectToXML(_taskCollection);
            return task;
            
        }

        public MyManager.Business.Task Update(Business.Task task)
        {
            throw new NotImplementedException();
        }

        public int Delete(string taskId)
        {
            throw new NotImplementedException();
        }

        public Business.Task GetTaskById(string taskId)
        {
            return _taskCollection.Single<MyManager.Business.Task>(task => task.Id == taskId);
        }

        public TaskCollection GetTasksByCategoryIds(System.Collections.Specialized.StringCollection categoryIds)
        {
            throw new NotImplementedException();
        }

        public TaskCollection GetTasksByDateRange(DateTime fromDate, DateTime toDate)
        {
            throw new NotImplementedException();
        }

        public TaskCollection GetTasksByStatus(Business.TaskStatus status)
        {
            throw new NotImplementedException();
        }

        public TaskCollection GetInProgressTasks(DateTime dateTime)
        {
            throw new NotImplementedException();
        }

        public TaskCollection GetOverDueTasks(DateTime dateTime)
        {
            throw new NotImplementedException();
        }


    }
}
